#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include </usr/share/systemtap/runtime/uprobes/uprobes.h>
#include <linux/kthread.h>
#include "scan_task.h"

static const char * module_name = "selfprobe module";
static struct task_struct *ts = NULL;

#if 0
static int pid = 0;
module_param(pid, int, 0);
MODULE_PARM_DESC(pid, "pid");
#endif

static int thread_start(void){
	int n = 0;
	printk(KERN_ERR"%s creating kthread \n", module_name );
	ts = kthread_run(scan_task, NULL, module_name );
	if( IS_ERR( ts ) ){
		printk(KERN_ERR "%s create kthread failed\n", module_name );
		n = -1;
	}else{
		printk(KERN_ERR"%s create kthread succeed\n", module_name );
	}
	return n;
}

static void thread_stop(void){
	printk(KERN_ERR"%s stop kthread\n", module_name );
	kthread_stop(ts);
	return;
}
int __init init_module(void){
	printk(KERN_ERR "%s init\n", module_name);
	return thread_start();
}
void __exit cleanup_module(void){
	thread_stop();
	printk(KERN_ERR "%s clearup\n", module_name);
	return;
}
MODULE_LICENSE("GPL");
